﻿using AutoMapper;
using Common.Damin;
using Common.Infrastructrue.Interface;
using Common.Service;
using MediatR;
using RabitPart.WritedPartApi.Application.Comman.TraceabilityFile;

namespace RabitPart.WritedPartApi.Application.CommanHandel.TraceabilityFile
{
    public class TraceabilityDelecteCommanHandel : IRequestHandler<TraceabilityDelecteComman, ApiResult>
    {
        private readonly ICompanymanageResponstity companyRE;
        private readonly IMapper mapper;
        private readonly ILogger<TraceabilityDelecteCommanHandel> logger;

        public TraceabilityDelecteCommanHandel(ICompanymanageResponstity companyRE, IMapper mapper, ILogger<TraceabilityDelecteCommanHandel> logger)
        {
            this.companyRE = companyRE;
            this.mapper = mapper;
            this.logger = logger;
        }


        public async Task<ApiResult> Handle(TraceabilityDelecteComman request, CancellationToken cancellationToken)
        {
            var company = mapper.Map<Companymanage>(request);
            company.IsDelete = false;
            await companyRE.UpdateAsync(company);
            return await Task.FromResult(ApiResult.Success(StatusCodeEnum.Ok));

        }
    }
}
